package com.xkdx.caipiao.open;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;
import com.xkdx.caipiao.presistence.quert.OpenAwardNumQueryInfo;
import com.xkdx.caipiao.presistence.quert.OpenAwardNumQueryItemInfo;

public class OpenHistoryQueryModule extends AbsModule {
	public OpenAwardNumQueryInfo info;
	public boolean isSuccess = false;

	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("BeforeOrderAwardQuery")) {
					parseOpenAwardNumQuery(jsonObj.getJSONArray("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private void parseOpenAwardNumQuery(JSONArray array) throws Exception {
		try {
			if (array != null && array.size() > 0) {
				info = new OpenAwardNumQueryInfo();
				List<OpenAwardNumQueryItemInfo> list = new ArrayList<OpenAwardNumQueryItemInfo>();
				for (int i = 0; i < array.size(); i++) {
					JSONObject obj = array.getJSONObject(i);
					OpenAwardNumQueryItemInfo item = new OpenAwardNumQueryItemInfo();
					item.setDesc(obj.getString(OpenAwardNumQueryItemInfo.DESC));
					item.setFirstprize(obj
							.getString(OpenAwardNumQueryItemInfo.FIRSTPRIZE));
					item.setIcon(obj.getString(OpenAwardNumQueryItemInfo.ICON));
					item.setIssueid(obj
							.getString(OpenAwardNumQueryItemInfo.ISSUEID));
					item.setLotteryid(obj
							.getString(OpenAwardNumQueryItemInfo.LOTTERYID));
					item.setOpenawardtime(obj
							.getString(OpenAwardNumQueryItemInfo.OPENAWARDTIME));
					item.setOpennum(obj
							.getString(OpenAwardNumQueryItemInfo.OPENNUM));
					item.setPool(obj.getString(OpenAwardNumQueryItemInfo.POOL));
					item.setThreeprize(obj
							.getString(OpenAwardNumQueryItemInfo.THREEPRIZE));
					item.setTwoprize(obj
							.getString(OpenAwardNumQueryItemInfo.TWOPRIZE));

					list.add(item);
				}
				info.setList(list);
			}
		} catch (Exception e) {
			throw e;
		}

	}

}
